package com.dream.testtubebaby_doctor;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.dream.testtubebaby_doctor.utils.ImageLoader;
import com.dream.testtubebaby_doctor.utils.ImageLoader.Type;

public class LookupImageActivity extends Activity {
	public static final String LOOKUP_IMAGE_PATH_KEY = "lookup_image_path";
	public static final String LOOKUP_IMAGE_TYPE = "lookup_image_type";
	public static final int LOCAL_IMAGE = 1;
	public static final int NETWORK_IMAGE = 2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_lookup_image);
		initView();
	}

	private void initView() {
		String url = getIntent().getStringExtra(LOOKUP_IMAGE_PATH_KEY);
		ImageView lookup_image = (ImageView) findViewById(R.id.lookup_image);
		int type = getIntent().getIntExtra(LOOKUP_IMAGE_TYPE, LOCAL_IMAGE);
		if (type == LOCAL_IMAGE) {
			ImageLoader.getInstance(3, Type.LIFO).loadLookupImage(url,
					lookup_image);
		} else if (type == NETWORK_IMAGE) {
			ImageLoader.getInstance(3, Type.LIFO).loadLookupNetworkImage(url,
					lookup_image);
		}
		// BitmapFactory.decodeFile(url);
		// lookup_image.setImageBitmap(BitmapFactory.decodeFile(url));
		lookup_image.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}
}
